/**
 * admui-basic v2.1.0 (http://www.admui.com/)
 * Copyright 2015-2019 Admui Team
 * Licensed under the Admui License 1.1 (http://www.admui.com/about/license)
 */
(function(document, window, $) {
  'use strict';

  /* global toastr */

  // 图表示例
  var charts = {
    example1: function() {
      // 实时显示示例
      var $exampleFlotRealtime = $('#exampleFlotRealtime');
      var data;
      var totalPoints;
      var labelColor;
      var updateInterval;
      var plot;

      if (!$.isFunction($.fn.plot) || $exampleFlotRealtime.length === 0) {
        return;
      }

      data = [];
      totalPoints = 250;

      // 获取随机数据
      function getRandomData() {
        var prev;
        var y;
        var res;
        var i = 0;

        if (data.length > 0) {
          data = data.slice(1);
        }
        // 随机数
        while (data.length < totalPoints) {
          prev = data.length > 0 ? data[data.length - 1] : 50;
          y = prev + Math.random() * 10 - 5;
          if (y < 0) {
            y = 0;
          } else if (y > 100) {
            y = 100;
          }
          data.push(y);
        }
        // 与X轴对应产生Y轴随机数
        res = [];
        for (; i < data.length; i += 1) {
          res.push([i, data[i]]);
        }
        return res;
      }

      labelColor = $.getColor('grey', 600);
      // 设置控制部件
      updateInterval = 30;

      plot = $.plot(
        $exampleFlotRealtime,
        [
          {
            data: getRandomData()
          }
        ],
        {
          colors: [$.getColor('blue-grey', 100)],
          series: {
            shadowSize: 0,
            lines: {
              show: true,
              lineWidth: 0,
              fill: true,
              fillColor: $.getColor('blue-grey', 100)
            }
          },
          legend: {
            show: false
          },
          xaxis: {
            show: false,
            font: {
              color: labelColor
            }
          },
          yaxis: {
            tickColor: '#edeff2',
            color: '#474e54',
            min: 0,
            max: 100,
            font: {
              size: 14,
              color: labelColor,
              weight: '300'
              // family: "OpenSans Light"
            }
          },
          grid: {
            color: '#474e54',
            tickColor: '#e3e6ea',
            backgroundColor: {
              colors: ['#fff', '#fff']
            },
            borderWidth: {
              top: 0,
              right: 0,
              bottom: 1,
              left: 0
            },
            borderColor: '#eef0f2'
          }
        }
      );

      // 更新图表数据
      function update() {
        plot.setData([getRandomData()]);
        // 轴不发生变化，我们并不需要调用plot.setupGrid（）
        plot.draw();
        setTimeout(update, updateInterval);
      }

      update();
    },
    example2: function() {
      // 全背景曲线图示例
      var b = [
        [1262304000000, 0],
        [1264982400000, 500],
        [1267401600000, 700],
        [1270080000000, 1300],
        [1272672000000, 2600],
        [1275350400000, 1300],
        [1277942400000, 1700],
        [1280620800000, 1300],
        [1283299200000, 1500],
        [1285891200000, 2000],
        [1288569600000, 1500],
        [1291161600000, 1200]
      ];
      var a = [
        {
          label: '值',
          data: b
        }
      ];

      $.plot('#exampleFlotFullBg', a, {
        xaxis: {
          min: new Date(2009, 12, 1).getTime(),
          max: new Date(2010, 11, 2).getTime(),
          mode: 'time',
          tickSize: [1, '月'],
          monthNames: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
          tickLength: 0,
          // tickColor: "#edeff2",
          color: '#474e54',
          font: {
            size: 14,
            weight: 300
            // family: "OpenSans Light"
          }
        },
        yaxis: {
          tickColor: '#edeff2',
          color: '#474e54',
          font: {
            size: 14,
            weight: '300'
            // family: "OpenSans Light"
          }
        },
        series: {
          shadowSize: 0,
          lines: {
            show: true,
            // fill: true,
            // fillColor: "#ff0000",
            lineWidth: 1.5
          },
          points: {
            show: true,
            fill: true,
            fillColor: $.getColor('purple', 600),
            radius: 3,
            lineWidth: 1
          }
        },
        colors: [$.getColor('purple', 400)],
        grid: {
          // show: true,
          hoverable: true,
          clickable: true,
          // color: "green",
          // tickColor: "red",
          backgroundColor: {
            colors: ['#fcfdfe', '#fcfdfe']
          },
          borderWidth: 0
          // borderColor: "#ff0000"
        },
        legend: {
          show: false
        }
      });
    },
    example3: function() {
      // 曲线图示例
      var dt1 = [];
      var i = 0;
      var dt2 = [];
      var fChart = $('#exampleFlotCurve');

      for (; i < Math.PI * 2; i += 0.25) {
        dt1.push([i, Math.sin(i)]);
      }

      for (i = 0; i < Math.PI * 2; i += 0.25) {
        dt2.push([i, Math.cos(i)]);
      }

      $.plot(
        fChart,
        [
          {
            label: 'sin(x)',
            data: dt1,
            color: $.getColor('purple', 400),
            points: {
              show: true,
              fill: true,
              radius: 3,
              fillColor: $.getColor('purple', 400)
            }
          },
          {
            label: 'cos(x)',
            data: dt2,
            yaxis: 2,
            color: $.getColor('green', 400),
            points: {
              show: true,
              fill: true,
              radius: 3,
              fillColor: $.getColor('green', 600)
            }
          }
        ],
        {
          series: {
            shadowSize: 0,
            lines: {
              show: true,
              lineWidth: 1.5
            },
            points: {
              show: true,
              radius: 3,
              lineWidth: 1
            }
          },
          xaxes: [
            {
              ticks: [
                0,
                [Math.PI / 2, '\u03c0/2'],
                [Math.PI, '\u03c0'],
                [(Math.PI * 3) / 2, '3\u03c0/2'],
                [Math.PI * 2, '2\u03c0']
              ]
            }
          ],
          yaxes: [
            {
              ticks: 5,
              min: -2,
              max: 2,
              tickDecimals: 3
            },
            {
              ticks: 5,
              min: -1,
              max: 1,
              tickLength: 0,
              tickDecimals: 2,
              position: 'right'
            }
          ],
          grid: {
            hoverable: true,
            color: '#474e54',
            tickColor: '#e3e6ea',
            backgroundColor: {
              colors: ['#fff', '#fff']
            },
            borderWidth: {
              top: 1,
              right: 1,
              bottom: 1,
              left: 1
            },
            borderColor: '#eef0f2'
          },
          legend: {
            show: false
          }
        }
      );
    },
    example4: function() {
      // 混合图示例
      var i = 0;
      var n = 0;
      var z = 0;
      var m = 0;
      var x = 0;
      var b1 = [];
      var b2 = [[2, 3], [4, 8], [6, 5], [9, 13]];
      var b3 = [];
      var b4 = [];
      var b5 = [];
      var b6 = [];
      for (; i < 14; i += 0.5) {
        b1.push([i, Math.cos(i) + 1]);
      }

      for (; m < 14; m += 0.5) {
        b3.push([m, Math.cos(m) + Math.sin(m) - 1]);
      }

      for (; n < 14; n += 0.1) {
        b4.push([n, Math.sqrt(n * 10) - 4 * Math.cos(n)]);
      }

      for (; z < 14; z += 1.5) {
        b5.push([z, Math.cos(z) + 2 * Math.sin(z) + 6]);
      }

      for (x; x < 14; x += 0.5 + Math.random()) {
        b6.push([x, Math.sqrt(x + 2 * Math.cos(x)) - Math.sin(x) - 3]);
      }

      $.plot(
        '#exampleFlotMix',
        [
          {
            data: b2,
            bars: {
              show: true,
              align: 'center',
              fill: true,
              fillColor: $.getColor('blue-grey', 100)
            }
          },
          {
            data: b1,
            lines: {
              show: true,
              fill: true,
              fillColor: 'rgba(251,213,181,.1)'
            }
          },
          {
            data: b3,
            points: {
              show: true,
              fill: true,
              fillColor: $.getColor('green', 600),
              radius: 2
            }
          },
          {
            data: b4,
            lines: {
              show: true
            },
            points: {
              show: false
            }
          },
          {
            data: b5,
            lines: {
              show: true
            },
            points: {
              show: true,
              fill: true,
              fillColor: $.getColor('purple', 600),
              radius: 2
            }
          },
          {
            data: b6,
            lines: {
              show: true,
              steps: true
            }
          }
        ],
        {
          xaxis: {
            tickLength: 0,
            color: '#474e54',
            font: {
              size: 14,
              weight: 300
              // family: "OpenSans Light"
            }
          },
          yaxis: {
            tickColor: '#edeff2',
            color: '#474e54',
            font: {
              size: 14,
              weight: '300'
              // family: "OpenSans Light"
            }
          },
          grid: {
            color: '#474e54',
            tickColor: '#e3e6ea',
            backgroundColor: {
              colors: ['#fff', '#fff']
            },
            borderWidth: {
              top: 0,
              right: 0,
              bottom: 1,
              left: 0
            },
            borderColor: '#eef0f2'
          },
          series: {
            shadowSize: 0
          },
          colors: [
            $.getColor('blue-grey', 100),
            $.getColor('orange', 200),
            $.getColor('green', 600),
            $.getColor('yellow', 600),
            $.getColor('purple', 600),
            $.getColor('purple', 200)
          ]
        }
      );
    },
    example5: function() {
      // 堆叠柱状图示例
      var i = 1;
      var a1 = [];
      var a2 = [];
      var a3 = [];
      var a4 = [];

      for (; i <= 4; i += 1) {
        a1.push([i, parseInt(Math.random() * 30, 10)]);
      }

      for (i = 1; i <= 4; i += 1) {
        a2.push([i, parseInt(Math.random() * 30, 10)]);
      }

      for (i = 1; i <= 4; i += 1) {
        a3.push([i, parseInt(Math.random() * 30, 10)]);
      }

      for (i = 1; i <= 4; i += 1) {
        a4.push([i, parseInt(Math.random() * 30 - 10, 10)]);
      }

      $.plot(
        '#exampleFlotStackBar',
        [
          {
            data: a1,
            bars: {
              fill: true,
              fillColor: $.getColor('light-green', 500)
            }
          },
          {
            data: a2,
            bars: {
              fill: true,
              fillColor: $.getColor('blue-grey', 300)
            }
          },
          {
            data: a3,
            bars: {
              fill: true,
              fillColor: $.getColor('purple', 500)
            }
          },
          {
            data: a4,
            bars: {
              fill: true,
              fillColor: $.getColor('purple', 500)
            }
          }
        ],
        {
          series: {
            stack: true,
            shadowSize: 0,
            lines: {
              show: false,
              fill: true,
              steps: false
            },
            bars: {
              show: true,
              align: 'center',
              barWidth: 0.38
            }
          },
          colors: [
            $.getColor('light-green', 500),
            $.getColor('blue-grey', 300),
            $.getColor('purple', 500),
            $.getColor('purple', 500)
          ],
          xaxis: {
            tickLength: 0,
            color: '#474e54',
            min: 0,
            max: 5.5,
            ticks: [1, 2, 3, 4],
            font: {
              size: 14,
              weight: 300
              // family: "OpenSans Light"
            }
          },
          yaxis: {
            tickColor: '#edeff2',
            color: '#474e54',
            min: -10,
            font: {
              size: 14,
              weight: '300'
              // family: "OpenSans Light"
            }
          },
          grid: {
            color: '#474e54',
            tickColor: '#e3e6ea',
            backgroundColor: {
              colors: ['#fff', '#fff']
            },
            borderWidth: {
              top: 0,
              right: 0,
              bottom: 1,
              left: 0
            },
            borderColor: '#eef0f2'
          }
        }
      );
    },
    example6: function() {
      // 横向柱状图示例
      var i = 1;
      var n = 1;
      var z = 1;
      var a11 = [];
      var a22 = [];
      var a33 = [];

      for (; i <= 5; i += 1) {
        a11.push([parseInt(Math.random() * 30, 10), i]);
      }

      for (; n <= 5; n += 1) {
        a22.push([parseInt(Math.random() * 30, 10), n]);
      }

      for (z; z <= 5; z += 1) {
        a33.push([parseInt(Math.random() * 30, 10), z]);
      }

      $.plot(
        '#exampleFlotHorizontalBar',
        [
          {
            data: a11,
            bars: {
              fill: true,
              fillColor: $.getColor('purple', 500)
            }
          },
          {
            data: a22,
            bars: {
              fill: true,
              fillColor: $.getColor('blue-grey', 300)
            }
          },
          {
            data: a33,
            bars: {
              fill: true,
              fillColor: $.getColor('red', 500)
            }
          }
        ],
        {
          series: {
            stack: true,
            lines: {
              show: false,
              fill: true
            },
            bars: {
              show: true,
              barWidth: 0.55,
              align: 'center',
              horizontal: true
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 300), $.getColor('red', 500)],
          xaxis: {
            color: '#474e54',
            font: {
              size: 14,
              weight: 300
              // family: "OpenSans Light"
            }
          },
          yaxis: {
            tickLength: 0,
            tickColor: '#edeff2',
            color: '#474e54',
            min: 0,
            max: 6,
            ticks: [1, 2, 3, 4, 5],
            font: {
              size: 14,
              weight: '300'
              // family: "OpenSans Light"
            }
          },
          grid: {
            color: '#474e54',
            tickColor: '#e3e6ea',
            backgroundColor: {
              colors: ['#fff', '#fff']
            },
            borderWidth: {
              top: 1,
              right: 1,
              bottom: 1,
              left: 1
            },
            borderColor: '#eef0f2'
          }
        }
      );
    },
    example7: function() {
      // 饼状图示例
      var pieData = [];
      var series = 2;
      var $btnPieDefault = $('#btnPieDefault');
      var placeholder = $('#exampleFlotPie');
      var i = 0;

      for (; i < series; i += 1) {
        pieData[i] = {
          label: '示例' + (i + 1),
          data: Math.floor(Math.random() * 100) + 1
        };
      }

      // 使用自定义标签
      function labelFormatter(label, val) {
        return (
          '<div' +
          " style='" +
          "font-size: 8pt; text-align: center; padding: 2px; color: #747474;'" +
          '>' +
          label +
          '<br/>' +
          Math.round(val.percent) +
          '%</div>'
        );
      }

      // 默认
      $btnPieDefault.click(function() {
        placeholder.unbind();

        $.plot(placeholder, pieData, {
          series: {
            pie: {
              show: true
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 200)]
        });
      });

      // 隐藏图例
      $('#btnPieWithoutLegend').click(function() {
        placeholder.unbind();

        $.plot(placeholder, pieData, {
          series: {
            pie: {
              show: true,
              label: {
                show: true
              }
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 200)],
          legend: {
            show: false
          }
        });
      });

      // 圆形
      $('#btnPieLabelRadius').click(function() {
        placeholder.unbind();

        $.plot(placeholder, pieData, {
          series: {
            pie: {
              show: true,
              radius: 1,
              label: {
                show: true,
                radius: 3 / 4,
                formatter: labelFormatter
              }
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 200)],
          legend: {
            show: false
          }
        });
      });

      // 矩形
      $('#btnPieRectangular').click(function() {
        placeholder.unbind();

        $.plot(placeholder, pieData, {
          series: {
            pie: {
              show: true,
              radius: 500,
              label: {
                show: true,
                formatter: labelFormatter,
                threshold: 0.1
              }
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 200)],
          legend: {
            show: false
          }
        });
      });

      // 环形
      $('#btnPieDonutHole').click(function() {
        placeholder.unbind();

        $.plot(placeholder, pieData, {
          series: {
            pie: {
              innerRadius: 0.5,
              show: true
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 200)]
        });
      });

      // 动态
      $('#btnPieInteractivity').click(function() {
        placeholder.unbind();

        $.plot(placeholder, pieData, {
          series: {
            pie: {
              show: true
            }
          },
          colors: [$.getColor('purple', 500), $.getColor('blue-grey', 200)],
          grid: {
            hoverable: true,
            clickable: true
          }
        });

        placeholder.bind('plothover', function(event, pos, obj) {
          var percent;
          if (!obj) {
            return;
          }

          percent = parseFloat(obj.series.percent).toFixed(2);
          $('#hover').html(
            "<span style='font-weight:bold; color:" +
              obj.series.color +
              "'>" +
              obj.series.label +
              ' (' +
              percent +
              '%)</span>'
          );
        });

        placeholder.bind('plotclick', function(event, pos, obj) {
          var percent;
          if (!obj) {
            return;
          }

          percent = parseFloat(obj.series.percent).toFixed(2);
          toastr.info('' + obj.series.label + ': ' + percent + '%');
        });
      });

      // 显示初始默认图表
      $btnPieDefault.click();
    },
    example8: function() {
      // 访客图示例
      var i = 0;
      var d = [
        [1196463600000, 0],
        [1196550000000, 0],
        [1196636400000, 0],
        [1196722800000, 77],
        [1196809200000, 3636],
        [1196895600000, 3575],
        [1196982000000, 2736],
        [1197068400000, 1086],
        [1197154800000, 676],
        [1197241200000, 1205],
        [1197327600000, 906],
        [1197414000000, 710],
        [1197500400000, 639],
        [1197586800000, 540],
        [1197673200000, 435],
        [1197759600000, 301],
        [1197846000000, 575],
        [1197932400000, 481],
        [1198018800000, 591],
        [1198105200000, 608],
        [1198191600000, 459],
        [1198278000000, 234],
        [1198364400000, 1352],
        [1198450800000, 686],
        [1198537200000, 279],
        [1198623600000, 449],
        [1198710000000, 468],
        [1198796400000, 392],
        [1198882800000, 282],
        [1198969200000, 208],
        [1199055600000, 229],
        [1199142000000, 177],
        [1199228400000, 374],
        [1199314800000, 436],
        [1199401200000, 404],
        [1199487600000, 253],
        [1199574000000, 218],
        [1199660400000, 476],
        [1199746800000, 462],
        [1199833200000, 448],
        [1199919600000, 442],
        [1200006000000, 403],
        [1200092400000, 204],
        [1200178800000, 194],
        [1200265200000, 327],
        [1200351600000, 374],
        [1200438000000, 507],
        [1200524400000, 546],
        [1200610800000, 482],
        [1200697200000, 283],
        [1200783600000, 221],
        [1200870000000, 483],
        [1200956400000, 523],
        [1201042800000, 528],
        [1201129200000, 483],
        [1201215600000, 452],
        [1201302000000, 270],
        [1201388400000, 222],
        [1201474800000, 439],
        [1201561200000, 559],
        [1201647600000, 521],
        [1201734000000, 477],
        [1201820400000, 442],
        [1201906800000, 252],
        [1201993200000, 236],
        [1202079600000, 525],
        [1202166000000, 477],
        [1202252400000, 386],
        [1202338800000, 409],
        [1202425200000, 408],
        [1202511600000, 237],
        [1202598000000, 193],
        [1202684400000, 357],
        [1202770800000, 414],
        [1202857200000, 393],
        [1202943600000, 353],
        [1203030000000, 364],
        [1203116400000, 215],
        [1203202800000, 214],
        [1203289200000, 356],
        [1203375600000, 399],
        [1203462000000, 334],
        [1203548400000, 348],
        [1203634800000, 243],
        [1203721200000, 126],
        [1203807600000, 157],
        [1203894000000, 288]
      ];
      var options;
      var plot;
      var overview;

      for (; i < d.length; i += 1) {
        d[i][0] += 60 * 60 * 1000;
      }

      // 周区域
      function weekendAreas(axes) {
        var markings = [];
        var m = new Date(axes.xaxis.min);
        var n = m.getTime();

        m.setUTCDate(m.getUTCDate() - ((m.getUTCDay() + 1) % 7));
        m.setUTCSeconds(0);
        m.setUTCMinutes(0);
        m.setUTCHours(0);

        do {
          markings.push({
            xaxis: {
              from: n,
              to: n + 2 * 24 * 60 * 60 * 1000
            }
          });
          n += 7 * 24 * 60 * 60 * 1000;
        } while (n < axes.xaxis.max);

        return markings;
      }

      options = {
        series: {
          lines: {
            show: true,
            lineWidth: 1
          },
          shadowSize: 0
        },
        colors: [$.getColor('purple', 600)],
        selection: {
          mode: 'x',
          color: [$.getColor('purple', 300)]
        },
        xaxis: {
          tickLength: 0,
          mode: 'time',
          color: '#474e54',
          font: {
            size: 14,
            weight: 300
            // family: "OpenSans Light"
          }
        },
        yaxis: {
          tickColor: '#edeff2',
          color: '#474e54',
          font: {
            size: 14,
            weight: '300'
            // family: "OpenSans Light"
          }
        },
        grid: {
          markings: weekendAreas,
          color: '#474e54',
          tickColor: '#e3e6ea',
          backgroundColor: {
            colors: ['#fff', '#fff']
          },
          borderWidth: {
            top: 0,
            right: 0,
            bottom: 1,
            left: 0
          },
          borderColor: '#eef0f2'
        }
      };
      plot = $.plot('#exampleFlotVisitors', [d], options);
      overview = $.plot('#exampleFlotVisitorsOverview', [d], {
        series: {
          lines: {
            show: true,
            lineWidth: 1
          },
          shadowSize: 0
        },
        colors: [$.getColor('purple', 600)],
        xaxis: {
          ticks: [],
          mode: 'time'
        },
        yaxis: {
          ticks: [],
          min: 0,
          autoscaleMargin: 0.1
        },
        selection: {
          mode: 'x',
          color: [$.getColor('purple', 300)]
        },
        grid: {
          // markings: weekendAreas,
          color: '#474e54',
          tickColor: '#e3e6ea',
          backgroundColor: {
            colors: ['#fff', '#fff']
          },
          borderWidth: {
            top: 1,
            right: 1,
            bottom: 1,
            left: 1
          },
          borderColor: '#eef0f2'
        }
      });

      // 选中一片区域
      $('#exampleFlotVisitors').bind('plotselected', function(event, ranges) {
        $.each(plot.getXAxes(), function(_, axis) {
          var opts = axis.options;
          opts.min = ranges.xaxis.from;
          opts.max = ranges.xaxis.to;
        });
        plot.setupGrid();
        plot.draw();
        plot.clearSelection();

        overview.setSelection(ranges, true);
      });

      // 选中一片区域
      $('#exampleFlotVisitorsOverview').bind('plotselected', function(event, ranges) {
        plot.setSelection(ranges);
      });
    },
    example9: function() {
      // Tooltip 示例
      $("<div class='flot-tooltip'></div>")
        .css({
          position: 'absolute',
          color: '#fff',
          display: 'none',
          border: '1px solid #777',
          padding: '2px',
          'background-color': '#777',
          opacity: 0.8
        })
        .appendTo('body');

      // 鼠标移动到图表上
      $('#exampleFlotCurve').bind('plothover', function(event, pos, item) {
        var x;
        var y;

        if (item) {
          x = item.datapoint[0].toFixed(2);
          y = item.datapoint[1].toFixed(2);
          $('.flot-tooltip')
            .html(item.series.label + ' ：' + x + '，' + y)
            .css({
              top: item.pageY + 5,
              left: item.pageX + 5
            })
            .fadeIn(200);
        } else {
          $('.flot-tooltip').hide();
        }
      });

      // 鼠标移动到图表上
      $('#exampleFlotFullBg').bind('plothover', function(event, pos, item) {
        var x;
        var y;

        if (item) {
          x = item.datapoint[0].toFixed(2);
          y = item.datapoint[1].toFixed(2);
          $('.flot-tooltip')
            .html(item.series.label + ' ： ' + x + ' ， ' + y)
            .css({
              top: item.pageY + 5,
              left: item.pageX + 5
            })
            .fadeIn(200);
        } else {
          $('.flot-tooltip').hide();
        }
      });

      // 鼠标移动到图表上
      $('#exampleFlotRealtime').bind('plothover', function(event, pos, item) {
        var x;
        var y;

        if (item) {
          x = item.datapoint[0].toFixed(2);
          y = item.datapoint[1].toFixed(2);
          $('.flot-tooltip')
            .html('x | ' + x + ', y | ' + y)
            .css({
              top: item.pageY + 5,
              left: item.pageX + 5
            })
            .fadeIn(200);
        } else {
          $('.flot-tooltip').hide();
        }
      });
    }
  };

  $(function() {
    // 初始化图表示例
    $.each(charts, function(i, n) {
      n();
    });
  });
})(document, window, jQuery);
